package lcr;

import java.util.ArrayDeque;
import java.util.ArrayList;

public class Test0149_1 {
}

class Solution1049_1 {
    public int[] decorateRecord(TreeNode root) {
        if (root == null) return new int[0];

        ArrayDeque<TreeNode> deque = new ArrayDeque<>();
        deque.offer(root);
        ArrayList<Integer> list = new ArrayList<>();

        while (!deque.isEmpty()){
            TreeNode node = deque.poll();
            list.add(node.val);
            if (node.left != null){
                deque.offer(node.left);
            }
            if (node.right != null){
                deque.offer(node.right);
            }
        }

        int[] res = new int[list.size()];
        for (int i = 0; i < list.size(); i++) {
            res[i] = list.get(i);
        }

        return res;
    }
}
